package leetcodecompetition.D341;

import org.junit.jupiter.api.Test;

public class T6375 {
    public int addMinimum(String word) {

        int res=0;
        int sum = 1;
//        boolean boo = true;
        char left = word.charAt(0);
        for (int i = 1; i < word.length(); i++) {
            char c = word.charAt(i);
            if (c > left ) {
//                boo=true;
                sum++;
            } else {
                res+=3-sum;
//                boo=true;
                sum = 1;
            }
            left=c;
        }
        res+=3-sum;
        return res;
    }
    @Test
    public void test() {

        System.out.println(addMinimum("abaca"));

    }
}
